<html>
<head><meta charset="utf-8"><title>shrinking generators #52924 · wg-async-foundations · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/index.html">wg-async-foundations</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html">shrinking generators #52924</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="160025573"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/160025573" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#160025573">(Mar 05 2019 at 18:13)</a>:</h4>
<p>So the other issue is  Reuse generator slots after StorageDead <a href="https://github.com/rust-lang/rust/issues/52924" target="_blank" title="https://github.com/rust-lang/rust/issues/52924">#52924</a></p>



<a name="160025582"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/160025582" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#160025582">(Mar 05 2019 at 18:13)</a>:</h4>
<p>we had some discussion in the youtube video about the overall strategy</p>



<a name="160025597"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/160025597" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#160025597">(Mar 05 2019 at 18:13)</a>:</h4>
<p>however, I've not really looked into the code in question to see what is blocking that strategy from being implemented</p>



<a name="160025604"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/160025604" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#160025604">(Mar 05 2019 at 18:13)</a>:</h4>
<p><span class="user-mention" data-user-id="119009">@eddyb</span> -- do you happen to be around?</p>



<a name="160025900"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/160025900" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#160025900">(Mar 05 2019 at 18:17)</a>:</h4>
<p>(OK, I'm going to guess they're not right now)</p>



<a name="160025918"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/160025918" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#160025918">(Mar 05 2019 at 18:17)</a>:</h4>
<p>this sounds to me like a fun/interesting issue to tackle, but I'm not sure when I would be able to dig in (next week possibly?)</p>



<a name="160025922"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/160025922" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#160025922">(Mar 05 2019 at 18:17)</a>:</h4>
<p>Actually, <span class="user-mention" data-user-id="116466">@Zoxc</span> would likely know too, in case they are around</p>



<a name="160025926"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/160025926" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#160025926">(Mar 05 2019 at 18:17)</a>:</h4>
<p>Zulip won't notify me</p>



<a name="160025936"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/160025936" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#160025936">(Mar 05 2019 at 18:17)</a>:</h4>
<p>Hey <span class="user-mention" data-user-id="119009">@eddyb</span> =)</p>



<a name="160025952"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/160025952" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#160025952">(Mar 05 2019 at 18:17)</a>:</h4>
<p>We were discussing how to alter the layout of generators</p>



<a name="160025955"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/160025955" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#160025955">(Mar 05 2019 at 18:17)</a>:</h4>
<p>(if someone else wants to tackle it, feel free)</p>



<a name="160025957"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/160025957" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#160025957">(Mar 05 2019 at 18:17)</a>:</h4>
<p>so that they reuse slots</p>



<a name="160026013"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/160026013" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#160026013">(Mar 05 2019 at 18:18)</a>:</h4>
<p>I've discussed this with <span class="user-mention" data-user-id="127859">@Taylor Cramer</span> before</p>



<a name="160026015"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/160026015" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#160026015">(Mar 05 2019 at 18:18)</a>:</h4>
<p><span class="user-mention" data-user-id="127859">@Taylor Cramer</span> had mentioned the idea that you two discussed of using a simple heuristic to achieve better re-use</p>



<a name="160026025"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/160026025" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#160026025">(Mar 05 2019 at 18:18)</a>:</h4>
<p>Yes, but I was wondering -- what parts of the code would have to be modified?</p>



<a name="160026038"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/160026038" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#160026038">(Mar 05 2019 at 18:18)</a>:</h4>
<p>the general case is painful to implement, but the simple case should be relatively easy</p>



<a name="160026043"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/160026043" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#160026043">(Mar 05 2019 at 18:18)</a>:</h4>
<p>if <span class="user-mention" data-user-id="116466">@Zoxc</span> is around, you should ask them</p>



<a name="160026044"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/160026044" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#160026044">(Mar 05 2019 at 18:18)</a>:</h4>
<p>Basically, is this relatively straightforward, or will it require some bigger refactorings?</p>



<a name="160026065"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/160026065" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#160026065">(Mar 05 2019 at 18:18)</a>:</h4>
<p>(I was particularly concerned about whether it was ok for layout of a generator to depend on MIR.. I guess maybe it already does?)</p>



<a name="160026069"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/160026069" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#160026069">(Mar 05 2019 at 18:19)</a>:</h4>
<p>the simple case is "this is live only across one yield" <em>I think</em>?</p>



<a name="160026087"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/160026087" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#160026087">(Mar 05 2019 at 18:19)</a>:</h4>
<p>it already does</p>



<a name="160026089"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/160026089" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#160026089">(Mar 05 2019 at 18:19)</a>:</h4>
<p>right, this is what <span class="user-mention" data-user-id="127859">@Taylor Cramer</span> described</p>



<a name="160026096"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/160026096" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#160026096">(Mar 05 2019 at 18:19)</a>:</h4>
<p>OK, then it seems like it shouldn't be too hard to do</p>



<a name="160026186"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/160026186" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#160026186">(Mar 05 2019 at 18:20)</a>:</h4>
<p>so, you end up with a map from state to a list of locals only needed for that state (i.e. those lists are all disjoint)</p>



<a name="160026187"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/160026187" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#160026187">(Mar 05 2019 at 18:20)</a>:</h4>
<p>So, to fill in those of you who <em>didn't</em> follow the video the other day, the idea would be to identify data that is only live across a <strong>single yield</strong>, and then sort those bits of data by which yield they are live across. Things from yield X and yield Y can re-use the same storage slots</p>



<a name="160026206"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/160026206" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#160026206">(Mar 05 2019 at 18:20)</a>:</h4>
<p>But for things live across multiple yield, we can just put them each into their own storage slot</p>



<a name="160026211"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/160026211" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#160026211">(Mar 05 2019 at 18:20)</a>:</h4>
<p>this isn't optimal but would help a lot</p>



<a name="160026215"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/160026215" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#160026215">(Mar 05 2019 at 18:20)</a>:</h4>
<p>and would be efficient to compute</p>



<a name="160026234"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/160026234" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#160026234">(Mar 05 2019 at 18:20)</a>:</h4>
<p>(Sound about right, <span class="user-mention" data-user-id="119009">@eddyb</span>?)</p>



<a name="160026235"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/160026235" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#160026235">(Mar 05 2019 at 18:20)</a>:</h4>
<p>you would then use that to have an enum-like thing <em>after</em> the existing layout (which wouldn't contain any of those locals)</p>



<a name="160026249"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/160026249" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#160026249">(Mar 05 2019 at 18:20)</a>:</h4>
<p>Right ok</p>



<a name="160026259"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/160026259" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#160026259">(Mar 05 2019 at 18:21)</a>:</h4>
<p>so I guess somebody needs to dig into the existing layout code a bit to suggest how to alter</p>



<a name="160026270"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/160026270" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#160026270">(Mar 05 2019 at 18:21)</a>:</h4>
<p>my sense is that it seems of "medium" complexity</p>



<a name="160026272"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/160026272" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#160026272">(Mar 05 2019 at 18:21)</a>:</h4>
<p>well, what I described is how I think this would be sanely implemented, i.e. <em>without</em> trying to pair up locals</p>



<a name="160026278"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/160026278" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#160026278">(Mar 05 2019 at 18:21)</a>:</h4>
<p>not a trivial patch but not an epic quest either</p>



<a name="160026314"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/160026314" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#160026314">(Mar 05 2019 at 18:21)</a>:</h4>
<p>the layout code shouldn't be <em>too</em> hard, you kinda have to treat it like an <code>enum</code></p>



<a name="160026369"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/160026369" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#160026369">(Mar 05 2019 at 18:22)</a>:</h4>
<p>I guess we don't have enums with "common fields" today, heh</p>



<a name="160026388"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/160026388" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#160026388">(Mar 05 2019 at 18:22)</a>:</h4>
<p>I mean right now we handle generators <em>somehow</em></p>



<a name="160026391"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/160026391" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#160026391">(Mar 05 2019 at 18:22)</a>:</h4>
<p>right now we just make a struct</p>



<a name="160026407"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/160026407" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#160026407">(Mar 05 2019 at 18:22)</a>:</h4>
<p>with the state and all the locals ever saved</p>



<a name="160026422"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/160026422" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#160026422">(Mar 05 2019 at 18:22)</a>:</h4>
<p>ok, I see</p>



<a name="160026457"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/160026457" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#160026457">(Mar 05 2019 at 18:23)</a>:</h4>
<p>all right, we should break out these details into a separate topic</p>



<a name="160026463"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/160026463" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#160026463">(Mar 05 2019 at 18:23)</a>:</h4>
<p>there's no concept in the layout for "a struct with potentially-overlapping fields", sadly, that would be ideal here</p>



<a name="160026466"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/160026466" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#160026466">(Mar 05 2019 at 18:23)</a>:</h4>
<p>I guess the question is: does anybody who is present here today feel interested in trying to tackle this challenge</p>



<a name="160026470"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/160026470" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#160026470">(Mar 05 2019 at 18:23)</a>:</h4>
<p>yeah, split this entire conversation out, since you pinged me</p>



<a name="160026532"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/160026532" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#160026532">(Mar 05 2019 at 18:24)</a>:</h4>
<p>(PM me somewhere, ideally Discord, if you need help with the layout stuff. for the analysis on the MIR side, you'll likely need <span class="user-mention" data-user-id="116466">@Zoxc</span>)</p>



<a name="160026557"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/160026557" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#160026557">(Mar 05 2019 at 18:24)</a>:</h4>
<p>I'm interested as I mentioned</p>



<a name="160026569"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/160026569" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#160026569">(Mar 05 2019 at 18:24)</a>:</h4>
<p>I could also work on it as part of my upcoming contract but it might take a while to get to it</p>



<a name="160026576"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/160026576" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#160026576">(Mar 05 2019 at 18:24)</a>:</h4>
<p>(ok, separated)</p>



<a name="160026579"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/160026579" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#160026579">(Mar 05 2019 at 18:24)</a>:</h4>
<p>but not sure whether I will have bandwidth for it.. that should become clear later today :)</p>



<a name="160027615"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/160027615" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Taylor Cramer <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#160027615">(Mar 05 2019 at 18:35)</a>:</h4>
<p>Yeah <span class="user-mention" data-user-id="116883">@tmandry</span> we should chat about this later today :)</p>



<a name="160027739"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/160027739" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Taylor Cramer <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#160027739">(Mar 05 2019 at 18:36)</a>:</h4>
<p>As far as the "enum with shared fields" thing goes, I'd imagined there'd be some way to hide the actual types from MIR and keep the generator memory as roughly a "stack" of bytes</p>



<a name="160027762"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/160027762" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Taylor Cramer <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#160027762">(Mar 05 2019 at 18:37)</a>:</h4>
<p>We lose out on some optimization opportunities but it seems like a reasonable place to start</p>



<a name="160027780"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/160027780" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Taylor Cramer <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#160027780">(Mar 05 2019 at 18:37)</a>:</h4>
<p>I think <span class="user-mention" data-user-id="120791">@RalfJ</span> had opinions here</p>



<a name="160048905"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/160048905" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Taylor Cramer <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#160048905">(Mar 05 2019 at 22:53)</a>:</h4>
<p>trying again after adding them to the stream... <span class="user-mention" data-user-id="120791">@RalfJ</span></p>



<a name="160079659"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/160079659" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#160079659">(Mar 06 2019 at 09:22)</a>:</h4>
<p>I am mostly concerned about having a definition of a "valid" generator state (as in, the invariant that layout optimizations rely on) that can be reasonably checked by a UB sanitizer. Currently generators are treated as opaque by Miri because their fields dont actually all get properly initialized upon creation -- basically, the type information stored in the layout is lying when it claims that these fields always have these types. I think this is also why the layout code needs a special case to not find niches in generators.</p>



<a name="160109158"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/160109158" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#160109158">(Mar 06 2019 at 16:11)</a>:</h4>
<p>I imagine that if we take the 'enum-like' approach that <span class="user-mention" data-user-id="119009">@eddyb</span> was describing -- probably "union-like" is a better description -- this problem will go away</p>



<a name="160109166"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/160109166" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#160109166">(Mar 06 2019 at 16:11)</a>:</h4>
<p>but it's a good thing for us to try to fix at the same time</p>



<a name="160109322"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/160109322" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#160109322">(Mar 06 2019 at 16:13)</a>:</h4>
<p>that said, it seems like we might want a kind of separation -- what the <strong>MIR</strong> calls "field 0", for example, might want to map to a richer internal structure, I would think... i.e., internally the generator would have a kind of "union" of possibilities...</p>



<a name="160109352"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/160109352" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#160109352">(Mar 06 2019 at 16:13)</a>:</h4>
<p>...I have to look a bit at the code to try and make what I'm saying more precise.</p>



<a name="160114438"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/160114438" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Taylor Cramer <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#160114438">(Mar 06 2019 at 17:12)</a>:</h4>
<p>it certainly would be helpful to have a bit of information left over for debuginfo as well</p>



<a name="160117272"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/160117272" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#160117272">(Mar 06 2019 at 17:44)</a>:</h4>
<p>Yes, a good point</p>



<a name="160535605"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/160535605" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#160535605">(Mar 12 2019 at 01:54)</a>:</h4>
<p>Okay, I've begun digging into this and <a href="https://paper.dropbox.com/doc/Reuse-generator-slots-after-StorageDead-52924--AZIlWEta_TCSzCEq89IIz6PIAQ-BmtwrZorhqF5AjhFtPKLT" target="_blank" title="https://paper.dropbox.com/doc/Reuse-generator-slots-after-StorageDead-52924--AZIlWEta_TCSzCEq89IIz6PIAQ-BmtwrZorhqF5AjhFtPKLT">taking notes on what the implementation would require</a>. I'm very new to all of this code, so anyone that has familiarity with it is welcome to add to my notes / leave comments :)</p>



<a name="160535620"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/160535620" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#160535620">(Mar 12 2019 at 01:54)</a>:</h4>
<p>so far it's all pretty basic stuff, just finding out what code is involved etc</p>



<a name="161208151"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/161208151" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#161208151">(Mar 20 2019 at 01:50)</a>:</h4>
<p>Okay, so my current thinking is I have two possible approaches to making this work:</p>
<p>1) Actually create an enum type during the mir transform stage, with one variant for each yield point, and put it inside the <code>GeneratorLayout</code><br>
  - not entirely clear on how to propagate local def information through to debug info, this would probably require significant refactoring of that code<br>
2) Store all the information about fields only live across one yield point inside <code>GeneratorLayout</code>, and then eventually turn this into a custom layout with <code>FieldPlacement::Arbitrary</code>, essentially handling it the same as an enum.<br>
3) Maybe something else?</p>
<p>I haven't dug into how feasible each of these options is yet, thoughts/suggestions welcome!</p>



<a name="161225561"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/161225561" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Giles Cope <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#161225561">(Mar 20 2019 at 08:32)</a>:</h4>
<p>Debug - that's a good point. Which approach is likely to be kinder to debuggers trying to fathom what's going on with a generator?</p>



<a name="161230874"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/161230874" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Nemo157 <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#161230874">(Mar 20 2019 at 10:00)</a>:</h4>
<p>Debug is handled similar to function locals when the generator is running, currently all locals are declared as soon as the generator resumes, but I think this change will make it more needed to actually declare the correct locals based on current state</p>



<a name="161230900"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/161230900" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Nemo157 <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#161230900">(Mar 20 2019 at 10:00)</a>:</h4>
<p>There’s also the question of what to display when printing the generator value itself, I’m not sure what’s done currently</p>



<a name="161264822"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/161264822" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#161264822">(Mar 20 2019 at 16:34)</a>:</h4>
<p>(deleted)</p>



<a name="161264848"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/161264848" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#161264848">(Mar 20 2019 at 16:34)</a>:</h4>
<p>cc <span class="user-mention" data-user-id="119009">@eddyb</span></p>



<a name="161284585"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/161284585" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#161284585">(Mar 20 2019 at 19:50)</a>:</h4>
<p>btw <span class="user-mention" data-user-id="119009">@eddyb</span> has troubles with Zulip, you may get more mileage by pinging them on discord with a link to the comment</p>



<a name="161284675"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/161284675" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#161284675">(Mar 20 2019 at 19:51)</a>:</h4>
<p>oh it's this hard stuff</p>



<a name="161284704"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/161284704" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#161284704">(Mar 20 2019 at 19:51)</a>:</h4>
<p>I'm in a wg-grammar meeting (the first one I attended in several months...), but I'll try to multitask</p>



<a name="161286301"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/161286301" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#161286301">(Mar 20 2019 at 20:08)</a>:</h4>
<blockquote>
<p>1) Actually create an enum type during the mir transform stage</p>
</blockquote>
<p>there's no way to synthesize actual <code>enum</code> types during compilation, btw</p>



<a name="161286726"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/161286726" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#161286726">(Mar 20 2019 at 20:13)</a>:</h4>
<p><span class="user-mention" data-user-id="116883">@tmandry</span> only 2) is workable AFAICT. as for debuginfo, there shouldn't be any issues - I also need to get back to <a href="https://github.com/rust-lang/rust/pull/56278" target="_blank" title="https://github.com/rust-lang/rust/pull/56278">https://github.com/rust-lang/rust/pull/56278</a> soon, the follow-up to that should clean up the debuginfo generation logic and let us do more things with generators</p>



<a name="161287035"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/161287035" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#161287035">(Mar 20 2019 at 20:16)</a>:</h4>
<p><span class="user-mention" data-user-id="210267">@Nemo157</span> btw for debuggers printing the generator itself, we can piggyback on the new support for debugging <code>enum</code>s, which tells DWARF about variant types quite directly</p>



<a name="161287067"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/161287067" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#161287067">(Mar 20 2019 at 20:17)</a>:</h4>
<p>and because DWARF has little to no limitations to how weird layouts can be, pretty much anything should work!</p>



<a name="161290325"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/161290325" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#161290325">(Mar 20 2019 at 20:55)</a>:</h4>
<p>okay, thanks!</p>



<a name="161290372"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/161290372" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#161290372">(Mar 20 2019 at 20:55)</a>:</h4>
<p>I think I'll try to implement proper debuginfo in this PR, but if I hit issues, I can open a new blocking issue and wait on <a href="https://github.com/rust-lang/rust/issues/56278" target="_blank" title="https://github.com/rust-lang/rust/issues/56278">#56278</a></p>



<a name="161732317"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/161732317" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#161732317">(Mar 26 2019 at 05:08)</a>:</h4>
<p>Status update: I'm nearly done with an initial implementation. The analysis is done and now I'm working on the layout code. Most of the time has been spent understanding what's going on currently, the implementation itself doesn't seem that hard.</p>



<a name="161732325"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/161732325" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#161732325">(Mar 26 2019 at 05:08)</a>:</h4>
<p>cc <span class="user-mention" data-user-id="116009">@nikomatsakis</span> since I won't be able to make the wg meeting tomorrow</p>



<a name="161812115"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/161812115" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#161812115">(Mar 26 2019 at 23:16)</a>:</h4>
<p>(okay, so implementing the layout is definitely the harder part)</p>



<a name="161917245"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/161917245" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#161917245">(Mar 28 2019 at 02:19)</a>:</h4>
<p><span class="user-mention" data-user-id="119009">@eddyb</span> Right now <code>FieldPlacement::Arbitrary</code> lowers directly to an LLVM struct which iiuc doesn't support overlapping fields. Is it possible to use <code>FieldPlacement::Variant</code> and generate MIR that accesses the fields under a variant?</p>



<a name="161981424"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/161981424" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#161981424">(Mar 28 2019 at 18:47)</a>:</h4>
<p>(cc other people who might know... <span class="user-mention" data-user-id="116466">@Zoxc</span> <span class="user-mention" data-user-id="121053">@varkor</span> <span class="user-mention" data-user-id="123856">@Vadim Petrochenkov</span>)</p>



<a name="161981991"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/161981991" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#161981991">(Mar 28 2019 at 18:54)</a>:</h4>
<p>I'm just looking for a quick thumbs up/down on whether this approach is worth pursuing.. tackling it now unless I hear otherwise :)</p>



<a name="161982172"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/161982172" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#161982172">(Mar 28 2019 at 18:57)</a>:</h4>
<p>one problem I see is that I'd have to move the variant tag to field 0, in front of the generator upvars, which might break things elsewhere</p>



<a name="161982865"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/161982865" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#161982865">(Mar 28 2019 at 19:05)</a>:</h4>
<p>more specifically, I'm sure there is both code that assumes variant tags are at field index 0, and code that assumes that upvars start at index 0</p>



<a name="161983315"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/161983315" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#161983315">(Mar 28 2019 at 19:10)</a>:</h4>
<p>actually, it may not matter for codegen purposes. the MIR generation will always generate a direct field access to get the variant, as well as to the fields that should be valid across a particular suspension point.</p>



<a name="161983362"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/161983362" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#161983362">(Mar 28 2019 at 19:11)</a>:</h4>
<p>okay, this might work</p>



<a name="161989839"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/161989839" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Nemo157 <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#161989839">(Mar 28 2019 at 20:29)</a>:</h4>
<p><span class="user-mention" data-user-id="116883">@tmandry</span> I know that debuginfo definitely assumes upvars start at field index 0</p>



<a name="161989920"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/161989920" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Nemo157 <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#161989920">(Mar 28 2019 at 20:30)</a>:</h4>
<p>But that shouldn’t be hard to fixup</p>



<a name="161993420"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/161993420" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#161993420">(Mar 28 2019 at 21:15)</a>:</h4>
<p><span class="user-mention" data-user-id="210267">@Nemo157</span> thanks</p>



<a name="161993431"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/161993431" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#161993431">(Mar 28 2019 at 21:15)</a>:</h4>
<p>I'm going to try keeping them there first</p>



<a name="161994141"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/161994141" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#161994141">(Mar 28 2019 at 21:24)</a>:</h4>
<p>the tag is not before everything else? huh</p>



<a name="161994180"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/161994180" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#161994180">(Mar 28 2019 at 21:25)</a>:</h4>
<p>the field stuff is tricky... I don't think <code>FIeldPlacement::Variant</code> is a thing?</p>



<a name="161994197"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/161994197" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#161994197">(Mar 28 2019 at 21:25)</a>:</h4>
<p>maybe rename <code>Arbitrary</code> to <code>Disjoint</code> and add another variant... or maybe just a <code>disjoint</code> field to <code>Arbitrary</code></p>



<a name="161994212"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/161994212" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#161994212">(Mar 28 2019 at 21:25)</a>:</h4>
<p>so the "struct-like" situation only holds for <code>disjoint: true</code></p>



<a name="161994308"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/161994308" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#161994308">(Mar 28 2019 at 21:27)</a>:</h4>
<p><code>rustc_codegen_llvm</code> already has logic for accessing arbitrary offsets in non-struct-likes... unless that became unnecessary and got removed, heh</p>



<a name="161994397"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/161994397" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#161994397">(Mar 28 2019 at 21:28)</a>:</h4>
<p>you could try doing variants but idk if you can encode that in MIR nicely,  MIR variant "downcasting" requires an <code>AdtDef</code> (that the variant index indexes into)</p>



<a name="161994495"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/161994495" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#161994495">(Mar 28 2019 at 21:29)</a>:</h4>
<p>so I think "non-disjoint arbitrary offsets" that the LLVM backend has to work harder for, but doesn't introduce complexity anywhere else, is good. OTOH, using the variants stuff means miri can actually validity-check generators because there is a mapping from discriminant values to which fields should be initialized</p>



<a name="161994907"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/161994907" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#161994907">(Mar 28 2019 at 21:35)</a>:</h4>
<p>erm yeah, I meant to use <code>Variants::Tagged</code> instead of <code>Variants::Single</code></p>



<a name="161994978"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/161994978" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#161994978">(Mar 28 2019 at 21:36)</a>:</h4>
<p>basically treat it as an enum with a long, multi-field prefix</p>



<a name="161995034"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/161995034" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#161995034">(Mar 28 2019 at 21:37)</a>:</h4>
<p>ah I see about the <code>AdtDef</code>, I was a bit worried about something like that</p>



<a name="161995145"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/161995145" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#161995145">(Mar 28 2019 at 21:38)</a>:</h4>
<p>I would like to get miri able to do validity checking, but if it's a big refactor then it can wait..</p>



<a name="162650137"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/162650137" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#162650137">(Apr 05 2019 at 18:50)</a>:</h4>
<p>So, the way generators work now</p>



<a name="162650191"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/162650191" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#162650191">(Apr 05 2019 at 18:51)</a>:</h4>
<p>is that locals who are live across yields are <em>remapped</em> to fields of our generator struct</p>



<a name="162650326"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/162650326" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#162650326">(Apr 05 2019 at 18:52)</a>:</h4>
<p>this is fairly easily done, and means the MIR doesn't need to change much</p>



<a name="162650362"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/162650362" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#162650362">(Apr 05 2019 at 18:53)</a>:</h4>
<p>However, one interesting consequence of putting these locals in a tagged union, with one variant for each yield</p>



<a name="162650477"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/162650477" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#162650477">(Apr 05 2019 at 18:54)</a>:</h4>
<p>is that accesses of some locals, who (let's say) are only live across one yield point,<br>
may interleave with the accesses of locals who are only live across the next yield point</p>



<a name="162650579"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/162650579" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#162650579">(Apr 05 2019 at 18:55)</a>:</h4>
<p>If we were to follow the way the MIR transform is done today, this would lead to invalid codegen, because those locals might actually overlap in memory</p>



<a name="162651175"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/162651175" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#162651175">(Apr 05 2019 at 19:01)</a>:</h4>
<p>for example, let's pretend our generator looks like this</p>
<div class="codehilite"><pre><span></span><span class="k">fn</span> <span class="nf">my_generator</span><span class="p">()</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">  </span><span class="kd">let</span><span class="w"> </span><span class="n">x</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">foo</span><span class="p">();</span><span class="w"></span>
<span class="w">  </span><span class="kr">yield</span><span class="w"> </span><span class="mi">1</span><span class="p">;</span><span class="w"></span>
<span class="w">  </span><span class="kd">let</span><span class="w"> </span><span class="n">y</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">bar</span><span class="p">();</span><span class="w"></span>
<span class="w">  </span><span class="n">take</span><span class="p">(</span><span class="n">x</span><span class="p">);</span><span class="w"></span>
<span class="w">  </span><span class="kr">yield</span><span class="w"> </span><span class="mi">2</span><span class="p">;</span><span class="w"></span>
<span class="w">  </span><span class="n">take</span><span class="p">(</span><span class="n">y</span><span class="p">);</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</pre></div>


<p>then our generator type would look like this...</p>
<div class="codehilite"><pre><span></span><span class="k">enum</span> <span class="nc">MyGenerator</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">  </span><span class="n">Unresumed</span><span class="p">,</span><span class="w"></span>
<span class="w">  </span><span class="n">Complete</span><span class="p">,</span><span class="w"></span>
<span class="w">  </span><span class="n">Poisoned</span><span class="p">,</span><span class="w"></span>
<span class="w">  </span><span class="n">YieldedOnce</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="n">x</span><span class="w"> </span><span class="p">},</span><span class="w"></span>
<span class="w">  </span><span class="n">YieldedTwice</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="n">y</span><span class="w"> </span><span class="p">},</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</pre></div>


<p>when the generator is resumed after the first yield, the generated code would write to y, then read from x, which is bad because they share the same bytes in memory</p>



<a name="162651310"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/162651310" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#162651310">(Apr 05 2019 at 19:02)</a>:</h4>
<p>So, the solution to this is to move all the "locals" like this _out_ of the generator type and into <em>real</em> locals at the beginning of each resume</p>



<a name="162651354"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/162651354" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#162651354">(Apr 05 2019 at 19:03)</a>:</h4>
<p>But of course, for any locals which are borrowed, this could break things</p>



<a name="162651391"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/162651391" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#162651391">(Apr 05 2019 at 19:03)</a>:</h4>
<p>So the initial plan is for this optimization not to include any locals which are ever borrowed</p>



<a name="162651540"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/162651540" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#162651540">(Apr 05 2019 at 19:05)</a>:</h4>
<p>We have the information we need to make the optimization smarter than this, of course</p>



<a name="162651596"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/162651596" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#162651596">(Apr 05 2019 at 19:05)</a>:</h4>
<p><span class="user-mention" data-user-id="119009">@eddyb</span> and I were talking about this, and doing the "full" optimization is a lot like the NRVO optimization, which was quite expensive the last time they tried it</p>



<a name="162651606"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/162651606" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#162651606">(Apr 05 2019 at 19:05)</a>:</h4>
<p>cc <span class="user-mention" data-user-id="127859">@Taylor Cramer</span></p>



<a name="162652155"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/162652155" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#162652155">(Apr 05 2019 at 19:11)</a>:</h4>
<p>I think this also relates to some of the other issues around optimizations involving borrowed locals</p>



<a name="162652183"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/162652183" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#162652183">(Apr 05 2019 at 19:11)</a>:</h4>
<p>so maybe we can solve many of them with the same analysis</p>



<a name="162652243"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/162652243" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#162652243">(Apr 05 2019 at 19:12)</a>:</h4>
<p><em>assuming</em> we can find one that performs well.. :)</p>



<a name="162675377"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/162675377" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#162675377">(Apr 06 2019 at 00:54)</a>:</h4>
<p>Okay, so latest update is, we need to support some borrowed locals in order to optimize <code>await</code></p>



<a name="162675475"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/162675475" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#162675475">(Apr 06 2019 at 00:57)</a>:</h4>
<p>In the <code>await</code> case it is easier, because the borrowed future goes out of scope by the time we are done await'ing it</p>



<a name="162675493"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/162675493" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#162675493">(Apr 06 2019 at 00:58)</a>:</h4>
<p>So we decided to use storage liveness for this</p>



<a name="162675543"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/162675543" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#162675543">(Apr 06 2019 at 00:58)</a>:</h4>
<p>if we have two vars <code>x</code> and <code>y</code>, and every occurrence of <code>StorageLive(y)</code> is dominated by an occurrence of <code>StorageDead(x)</code>, then <code>x</code> and <code>y</code> can overlap in the generator type</p>



<a name="162675638"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/162675638" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#162675638">(Apr 06 2019 at 01:00)</a>:</h4>
<p>I'll look more into how to run this on monday</p>



<a name="162676226"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/162676226" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#162676226">(Apr 06 2019 at 01:16)</a>:</h4>
<p>but this would mean that we won't be moving things in and out of the generator struct, and will continue using the fields directly</p>



<a name="163236737"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/163236737" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#163236737">(Apr 12 2019 at 23:50)</a>:</h4>
<blockquote>
<p><span class="user-mention silent" data-user-id="210267">Nemo157</span> btw for debuggers printing the generator itself, we can piggyback on the new support for debugging <code>enum</code>s, which tells DWARF about variant types quite directly</p>
</blockquote>



<a name="163236754"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/163236754" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#163236754">(Apr 12 2019 at 23:51)</a>:</h4>
<p>I'm having trouble observing this behavior even for <code>enum</code>s</p>



<a name="163236830"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/163236830" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#163236830">(Apr 12 2019 at 23:52)</a>:</h4>
<p><span class="user-mention" data-user-id="210267">@Nemo157</span> should I be able to print an enum in gdb or lldb and see the fields inside it?</p>



<a name="163236870"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/163236870" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#163236870">(Apr 12 2019 at 23:53)</a>:</h4>
<p>(or anyone who knows)</p>



<a name="163283775"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/163283775" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#163283775">(Apr 13 2019 at 21:14)</a>:</h4>
<p>ah, gdb 8 seems to support this. newer lldb still doesn't seem to though</p>



<a name="163497783"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/163497783" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#163497783">(Apr 16 2019 at 19:10)</a>:</h4>
<p>Okay, so here's the current logic of the optimization:</p>
<ul>
<li>(1) Collect all locals with liveness across a yield point, meaning we need to store them (we do this today)</li>
<li>(2) Consider each local which is <em>storage live across only one yield point</em> a candidate for overlapping, and tentatively assign it to the layout variant for that particular yield point</li>
<li>(3) Run <code>MaybeStorageLive</code> dataflow analysis on MIR</li>
<li>(4) Iterate through every location in the MIR, and check to see which locals may have live storage at the same time. Record these potential conflicts in a bitset for each local.</li>
<li>(5) For every candidate local which has a potential conflict with another candidate local:<ul>
<li>If the candidate locals are both assigned to the same layout variant, there is no way their storage can overlap in memory. Do nothing.</li>
<li>If the candidate locals are assigned to different layout variants, pick one of them and remove its candidacy.</li>
</ul>
</li>
<li>(6) Now, each remaining candidate can be assigned to a single layout variant. Other stored locals are assigned to <em>all</em> layout variants, so they never overlap with one another.</li>
</ul>



<a name="163497801"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/163497801" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#163497801">(Apr 16 2019 at 19:10)</a>:</h4>
<p><span class="user-mention" data-user-id="116009">@nikomatsakis</span> ^</p>



<a name="163497921"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/163497921" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#163497921">(Apr 16 2019 at 19:12)</a>:</h4>
<p>sorry for weird formatting, zulip doesn't seem to handle numbered lists well</p>



<a name="163497974"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/163497974" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#163497974">(Apr 16 2019 at 19:13)</a>:</h4>
<p>Can you say a bit more about step 3?</p>
<blockquote>
<p>(3) Run MaybeStorageLive dataflow analysis on MIR</p>
</blockquote>
<p>What is this analysis more precisely?</p>



<a name="163498251"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/163498251" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#163498251">(Apr 16 2019 at 19:16)</a>:</h4>
<p><a href="https://github.com/rust-lang/rust/blob/9ebf47851a357faa4cd97f4b1dc7835f6376e639/src/librustc_mir/dataflow/impls/storage_liveness.rs#L7" target="_blank" title="https://github.com/rust-lang/rust/blob/9ebf47851a357faa4cd97f4b1dc7835f6376e639/src/librustc_mir/dataflow/impls/storage_liveness.rs#L7">here's the code</a></p>



<a name="163498295"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/163498295" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#163498295">(Apr 16 2019 at 19:16)</a>:</h4>
<p>it's a very simple analysis, only looking at StorageLive and StorageDead statements</p>



<a name="163498331"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/163498331" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#163498331">(Apr 16 2019 at 19:17)</a>:</h4>
<p>so one possibility is to make this smarter, and look to see if there are actual reads and writes past a certain point</p>



<a name="163498453"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/163498453" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#163498453">(Apr 16 2019 at 19:19)</a>:</h4>
<p>I may be wrong since I'm new to this, but dataflow analysis seems to propagate in the "forward" direction (perhaps it's a fixed point algorithm?), while this would need to propagate information "backwards"</p>



<a name="163498594"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/163498594" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#163498594">(Apr 16 2019 at 19:21)</a>:</h4>
<p>of course <a href="https://github.com/rust-lang/rust/blob/9ebf47851a357faa4cd97f4b1dc7835f6376e639/src/librustc_mir/util/liveness.rs" target="_blank" title="https://github.com/rust-lang/rust/blob/9ebf47851a357faa4cd97f4b1dc7835f6376e639/src/librustc_mir/util/liveness.rs"><code>rustc_mir::util::liveness</code></a> must be doing this somehow</p>



<a name="163498601"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/163498601" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#163498601">(Apr 16 2019 at 19:21)</a>:</h4>
<p>(I haven't looked at the code)</p>



<a name="163498740"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/163498740" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#163498740">(Apr 16 2019 at 19:23)</a>:</h4>
<p>however, "regular" liveness analysis doesn't work here, because it only cares about whether particular assignments are actually used, while we care about storage liveness (i.e., whether physical bytes should be reserved for future assignments)</p>



<a name="163498779"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/163498779" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#163498779">(Apr 16 2019 at 19:23)</a>:</h4>
<p>so all that to say, we could maybe come up with a way of combining these two approaches into something smarter than <code>MaybeStorageLive</code>, as you alluded to earlier in the meeting</p>



<a name="163498850"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/163498850" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#163498850">(Apr 16 2019 at 19:24)</a>:</h4>
<p>not sure if I'm being clear</p>



<a name="163499127"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/163499127" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#163499127">(Apr 16 2019 at 19:27)</a>:</h4>
<p>I <em>think</em> this can be done, but I haven't though through all of the details yet</p>



<a name="163499736"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/163499736" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#163499736">(Apr 16 2019 at 19:34)</a>:</h4>
<p>The other possible approach I see is one you also mentioned:<br>
Emitting <code>StorageDead</code> on the drop and unwind paths, at least for generators</p>
<ul>
<li>This means that some drop/unwind blocks that are currently "shared" between different points can no longer be shared; we'll have to produce an additional block that contains some <code>StorageDead</code> statements, followed by a jump to the original block</li>
<li>This could be combined with a sort of "storage liveness optimization" pass where we shrink the storage liveness range of locals, which may enable better space optimizations by my optimization pass described above<ul>
<li>We might want to do this eventually, regardless of the approach we take now.</li>
</ul>
</li>
</ul>



<a name="163499787"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/163499787" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#163499787">(Apr 16 2019 at 19:35)</a>:</h4>
<p>(ping <span class="user-mention" data-user-id="116009">@nikomatsakis</span> again :) )</p>



<a name="163500084"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/163500084" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#163500084">(Apr 16 2019 at 19:39)</a>:</h4>
<p><span class="user-mention" data-user-id="116883">@tmandry</span> thanks -- hmm,</p>



<a name="163500110"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/163500110" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#163500110">(Apr 16 2019 at 19:39)</a>:</h4>
<p>what I was proposing was indeed something more like a "liveness" analysis</p>



<a name="163500212"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/163500212" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#163500212">(Apr 16 2019 at 19:40)</a>:</h4>
<p>whether it's different from a normal liveness analysis depends a bit on your perspetive</p>



<a name="163500246"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/163500246" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#163500246">(Apr 16 2019 at 19:41)</a>:</h4>
<p>that is, <code>x = 5</code> -- while traditionally considered a "def" of <code>x</code> -- could in rust be considered a <em>use</em>, since it has to drop the previous value of <code>x</code> (though I guess this doesn't apply to integers)</p>



<a name="163500266"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/163500266" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#163500266">(Apr 16 2019 at 19:41)</a>:</h4>
<p>anyway the point would be that basically <em>everything</em> would be considered a <code>use</code> of the variable <strong>except</strong> <code>StorageLive</code></p>



<a name="163500273"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/163500273" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#163500273">(Apr 16 2019 at 19:41)</a>:</h4>
<p>which would be considered a def</p>



<a name="163500335"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/163500335" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#163500335">(Apr 16 2019 at 19:42)</a>:</h4>
<p>(though the semantics of StorageLive are a bit..odd -- it's not clear to me, for example, what happens if you have two StorageLive statements, one after the other -- is the second one a no-op?)</p>



<a name="163500361"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/163500361" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#163500361">(Apr 16 2019 at 19:42)</a>:</h4>
<blockquote>
<p>anyway the point would be that basically <em>everything</em> would be considered a <code>use</code> of the variable <strong>except</strong> <code>StorageLive</code></p>
</blockquote>
<p>yes, that sounds right</p>



<a name="163500364"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/163500364" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#163500364">(Apr 16 2019 at 19:42)</a>:</h4>
<p>but let's assume (which I presume is true) that this doesn't happen for us, and that there is only a single <code>StorageLive</code> for any given slot (or possibly zero)</p>



<a name="163500394"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/163500394" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#163500394">(Apr 16 2019 at 19:43)</a>:</h4>
<blockquote>
<p>(though the semantics of StorageLive are a bit..odd -- it's not clear to me, for example, what happens if you have two StorageLive statements, one after the other -- is the second one a no-op?)</p>
</blockquote>
<p>(I have found them odd too, including the lack of StorageDead along some paths, and wish there were a more formal definition somewhere)</p>



<a name="163500403"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/163500403" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#163500403">(Apr 16 2019 at 19:43)</a>:</h4>
<blockquote>
<p>yes, that sounds right</p>
</blockquote>
<p>well, hmm, so are we running this before or after drop elaboration?</p>



<a name="163500435"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/163500435" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#163500435">(Apr 16 2019 at 19:43)</a>:</h4>
<p>before</p>



<a name="163500491"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/163500491" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#163500491">(Apr 16 2019 at 19:44)</a>:</h4>
<p>so <em>really</em> what you want is something like <code>x = 5</code> is a use <em>iff</em> <code>x</code> is "maybe initialized"</p>



<a name="163500495"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/163500495" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#163500495">(Apr 16 2019 at 19:44)</a>:</h4>
<p>or wait, no</p>



<a name="163500507"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/163500507" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#163500507">(Apr 16 2019 at 19:44)</a>:</h4>
<p>sorry, I'm confused, as there's a drop elaboration step within the generator transform</p>



<a name="163500544"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/163500544" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#163500544">(Apr 16 2019 at 19:45)</a>:</h4>
<p>but the "regular" drop elaboration stage happens before us</p>



<a name="163500672"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/163500672" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#163500672">(Apr 16 2019 at 19:46)</a>:</h4>
<p>I think we can consider all locals like a "normal" function at this point</p>



<a name="163500708"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/163500708" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#163500708">(Apr 16 2019 at 19:47)</a>:</h4>
<p>are you sure?</p>



<a name="163500712"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/163500712" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#163500712">(Apr 16 2019 at 19:47)</a>:</h4>
<p>seems a bit odd</p>



<a name="163500714"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/163500714" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#163500714">(Apr 16 2019 at 19:47)</a>:</h4>
<p>but ok</p>



<a name="163500730"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/163500730" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#163500730">(Apr 16 2019 at 19:47)</a>:</h4>
<p>well, the analysis is running before we remap any locals to generator fields</p>



<a name="163500745"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/163500745" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#163500745">(Apr 16 2019 at 19:47)</a>:</h4>
<p>in that event, though, when you do <code>x = 5</code> that will get compiled into a regular assignment <em>but also</em> a kind of drop of the previous value</p>



<a name="163500815"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/163500815" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#163500815">(Apr 16 2019 at 19:48)</a>:</h4>
<p>but the real question is whether we create <code>StorageLive</code> for all things</p>



<a name="163500822"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/163500822" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#163500822">(Apr 16 2019 at 19:48)</a>:</h4>
<p>(e.g., even for temporaries etc?)</p>



<a name="163500857"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/163500857" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#163500857">(Apr 16 2019 at 19:48)</a>:</h4>
<p>there are some locals that never have <code>StorageLive</code> or <code>StorageDead</code> statements at all; these are not considered candidates for overlapping</p>



<a name="163500901"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/163500901" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#163500901">(Apr 16 2019 at 19:49)</a>:</h4>
<p>ok, I feel like they could be, but let's ignore them for now</p>



<a name="163500908"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/163500908" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#163500908">(Apr 16 2019 at 19:49)</a>:</h4>
<p>(they also have to be handled specially in the existing layout computation)</p>



<a name="163500923"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/163500923" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#163500923">(Apr 16 2019 at 19:49)</a>:</h4>
<p>if we do, and there's exactly one, it's not really important. I suspect we could do the analysis I talked about (indeed, a backwards analysis, and indeed it cannot use the generic dataflow framework then). We could implement it with datafrog, also.</p>



<a name="163500941"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/163500941" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#163500941">(Apr 16 2019 at 19:49)</a>:</h4>
<p>(liveness has custom code for this reason)</p>



<a name="163500998"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/163500998" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#163500998">(Apr 16 2019 at 19:50)</a>:</h4>
<p>the idea would roughly be "who cares if its storage is still live if we never look at it"</p>



<a name="163501028"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/163501028" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#163501028">(Apr 16 2019 at 19:50)</a>:</h4>
<p>but maybe I don't know what I'm talking about :)</p>



<a name="163501056"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/163501056" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#163501056">(Apr 16 2019 at 19:50)</a>:</h4>
<p>I'm a <em>bit</em> reluctant to modify the MIR generation though</p>



<a name="163501068"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/163501068" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#163501068">(Apr 16 2019 at 19:50)</a>:</h4>
<p>but I do also worry that we're being hand-wavy with our semantics</p>



<a name="163501102"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/163501102" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#163501102">(Apr 16 2019 at 19:51)</a>:</h4>
<p>and it'd be nice to try and write-out and document somewhat clearly what's going on here</p>



<a name="163501127"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/163501127" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#163501127">(Apr 16 2019 at 19:51)</a>:</h4>
<blockquote>
<p>the idea would roughly be "who cares if its storage is still live if we never look at it"</p>
</blockquote>
<p>it makes sense to me and I've been iterating on this for awhile (but the earlier iterations also made sense to me at first... ;) )</p>



<a name="163501268"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/163501268" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#163501268">(Apr 16 2019 at 19:53)</a>:</h4>
<blockquote>
<p>I'm a <em>bit</em> reluctant to modify the MIR generation though</p>
</blockquote>
<p>which part, the generation on drops and unwind paths?</p>



<a name="163501290"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/163501290" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#163501290">(Apr 16 2019 at 19:53)</a>:</h4>
<p>we wouldn't need that if we do the liveness approach, and if indeed that works, I'm inclined to do it that way</p>



<a name="163501395"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/163501395" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#163501395">(Apr 16 2019 at 19:54)</a>:</h4>
<blockquote>
<p>which part, the generation on drops and unwind paths?</p>
</blockquote>
<p>right</p>



<a name="163501409"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/163501409" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#163501409">(Apr 16 2019 at 19:54)</a>:</h4>
<p>because it could be a lot more IR, for one thing, and because I think it might be annoying</p>



<a name="163501415"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/163501415" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#163501415">(Apr 16 2019 at 19:54)</a>:</h4>
<p>and because it doesn't quite <em>feel</em> necessary</p>



<a name="163501523"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/163501523" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#163501523">(Apr 16 2019 at 19:56)</a>:</h4>
<p>okay, I'll try implementing the "storage liveness analysis"</p>



<a name="163501559"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/163501559" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#163501559">(Apr 16 2019 at 19:56)</a>:</h4>
<p>I feel like the terminology is getting confusing</p>



<a name="163501568"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/163501568" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#163501568">(Apr 16 2019 at 19:56)</a>:</h4>
<p>yeah that is probably a bad name :)</p>



<a name="163501615"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/163501615" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#163501615">(Apr 16 2019 at 19:57)</a>:</h4>
<p>sounds good, thanks :)</p>



<a name="163501626"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/163501626" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#163501626">(Apr 16 2019 at 19:57)</a>:</h4>
<p><em>has to run</em></p>



<a name="163502694"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/163502694" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#163502694">(Apr 16 2019 at 20:10)</a>:</h4>
<p>great</p>



<a name="163511992"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/163511992" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#163511992">(Apr 16 2019 at 22:16)</a>:</h4>
<p><span class="user-mention" data-user-id="116009">@nikomatsakis</span> ah I remember now why we cared about <code>StorageDead</code>, it's because of borrows</p>



<a name="163511999"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/163511999" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#163511999">(Apr 16 2019 at 22:16)</a>:</h4>
<p>oh, yes, ok</p>



<a name="163512000"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/163512000" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#163512000">(Apr 16 2019 at 22:16)</a>:</h4>
<p>unsafe code</p>



<a name="163512024"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/163512024" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#163512024">(Apr 16 2019 at 22:17)</a>:</h4>
<p>that, and right now the liveness analysis doesn't consider the uses of borrows in general</p>



<a name="163512028"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/163512028" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#163512028">(Apr 16 2019 at 22:17)</a>:</h4>
<p>well I guess any borrow</p>



<a name="163512034"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/163512034" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#163512034">(Apr 16 2019 at 22:17)</a>:</h4>
<p>yeah</p>



<a name="163512045"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/163512045" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#163512045">(Apr 16 2019 at 22:17)</a>:</h4>
<p>and we borrow the future in <code>await!()</code> which is specifically the case that I care about optimizing right now :)</p>



<a name="163512236"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/163512236" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#163512236">(Apr 16 2019 at 22:20)</a>:</h4>
<p>so, we may need a different approach</p>



<a name="163512468"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/163512468" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#163512468">(Apr 16 2019 at 22:22)</a>:</h4>
<p>one thing I realized with changing the drop/unwind MIR is, maybe we <em>can</em> stick with the blocks we have, but sprinkle extra <code>StorageDead</code> statements around (i.e., you might encounter a <code>StorageDead</code> without ever seeing a <code>StorageLive</code>)</p>



<a name="163512519"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/163512519" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#163512519">(Apr 16 2019 at 22:23)</a>:</h4>
<p>..then, when considering whether a local may be storage live in a block, if there are <code>StorageDead</code> statements at the beginning of the block, process all of those as part of the start of the block</p>



<a name="163512528"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/163512528" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#163512528">(Apr 16 2019 at 22:23)</a>:</h4>
<p>..this feels hacky, so maybe it's wrong :)</p>



<a name="163516246"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/163516246" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#163516246">(Apr 16 2019 at 23:21)</a>:</h4>
<p>^ the intuition above being "if two vars might both be StorageLive at the beginning of the block, but then one or both of them are immediately StorageDead before anything else happens, then it doesn't count"</p>



<a name="163516315"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/163516315" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#163516315">(Apr 16 2019 at 23:22)</a>:</h4>
<p>this still depends on adding <code>StorageDead</code> statements in certain places, though</p>



<a name="163521469"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/163521469" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#163521469">(Apr 17 2019 at 01:05)</a>:</h4>
<p>Okay, I think I'm going to try to prove out the optimization while generating full <code>StorageDead</code> statements everywhere</p>



<a name="163521592"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/163521592" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#163521592">(Apr 17 2019 at 01:07)</a>:</h4>
<p>then we can talk about ways to simplify the generated MIR (I think there are some, since unlike <code>drop</code>, <code>StorageDead</code> can happen multiple times, or even without having a <code>StorageLive</code>)</p>



<a name="163521610"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/163521610" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#163521610">(Apr 17 2019 at 01:07)</a>:</h4>
<p>Ironically, what I'm really trying to preserve is information about scopes here</p>



<a name="163521663"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/163521663" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#163521663">(Apr 17 2019 at 01:08)</a>:</h4>
<p>maybe we can use scope information directly...?</p>



<a name="163529188"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/163529188" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#163529188">(Apr 17 2019 at 04:00)</a>:</h4>
<p>i.e. if we know two vars are in scopes that are disjoint, then they're okay to overlap in storage</p>



<a name="163529215"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/163529215" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#163529215">(Apr 17 2019 at 04:01)</a>:</h4>
<p>although this precludes optimizations we might want to do later</p>



<a name="163530827"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/163530827" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#163530827">(Apr 17 2019 at 04:42)</a>:</h4>
<p>(ah nevermind, there's a reason scopes aren't preserved in MIR. sounds like <code>StorageDead</code> is the way.)</p>



<a name="163586746"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/163586746" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#163586746">(Apr 17 2019 at 18:13)</a>:</h4>
<p><span class="user-mention" data-user-id="116009">@nikomatsakis</span> any objection to the above?</p>



<a name="163688414"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/163688414" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#163688414">(Apr 18 2019 at 20:35)</a>:</h4>
<p><span class="user-mention" data-user-id="116009">@nikomatsakis</span> ping :)</p>



<a name="163751589"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/163751589" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#163751589">(Apr 19 2019 at 17:53)</a>:</h4>
<p>Hey <span class="user-mention" data-user-id="116883">@tmandry</span></p>



<a name="163751600"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/163751600" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#163751600">(Apr 19 2019 at 17:53)</a>:</h4>
<p>Sorry, yesterday I was basically tied up all day</p>



<a name="163751697"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/163751697" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#163751697">(Apr 19 2019 at 17:54)</a>:</h4>
<blockquote>
<p>any objection to the above?</p>
</blockquote>
<p>I'm not 100% sure what the proposal is, I guess</p>



<a name="163751732"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/163751732" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#163751732">(Apr 19 2019 at 17:55)</a>:</h4>
<p><span class="user-mention" data-user-id="120791">@RalfJ</span> -- apologies for subscribing you to this stream, but I have a quick question -- you were at some point writing up some kind of semantics for <code>StorageLive</code> and <code>StorageDead</code>, right?</p>



<a name="163751759"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/163751759" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#163751759">(Apr 19 2019 at 17:55)</a>:</h4>
<p><span class="user-mention" data-user-id="120791">@RalfJ</span> <span aria-label="point up" class="emoji emoji-1f446" role="img" title="point up">:point_up:</span></p>



<a name="163753205"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/163753205" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#163753205">(Apr 19 2019 at 18:14)</a>:</h4>
<blockquote>
<p>I'm not 100% sure what the proposal is, I guess</p>
</blockquote>
<p><span class="user-mention" data-user-id="116009">@nikomatsakis</span> it's to go ahead and emit <code>StorageDead</code> for everything along drop and unwind paths, so we're preserving the information that the optimization needs</p>



<a name="163753256"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/163753256" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#163753256">(Apr 19 2019 at 18:15)</a>:</h4>
<p>we could consider only doing it for generators</p>



<a name="163753337"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/163753337" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#163753337">(Apr 19 2019 at 18:16)</a>:</h4>
<blockquote>
<p><span class="user-mention silent" data-user-id="120791">RalfJ</span> -- apologies for subscribing you to this stream, but I have a quick question -- you were at some point writing up some kind of semantics for <code>StorageLive</code> and <code>StorageDead</code>, right?</p>
</blockquote>
<p>"writing up" is an overstatement^^</p>



<a name="163753347"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/163753347" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#163753347">(Apr 19 2019 at 18:16)</a>:</h4>
<p>I have a blog post at <a href="https://www.ralfj.de/blog/2017/06/06/MIR-semantics.html" target="_blank" title="https://www.ralfj.de/blog/2017/06/06/MIR-semantics.html">https://www.ralfj.de/blog/2017/06/06/MIR-semantics.html</a></p>



<a name="163753354"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/163753354" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#163753354">(Apr 19 2019 at 18:16)</a>:</h4>
<p>but mostly there is an implementation in Miri</p>



<a name="163753585"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/163753585" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#163753585">(Apr 19 2019 at 18:19)</a>:</h4>
<p>(I was also saying that, as an optimization, there might be ways to avoid creating new blocks of just <code>StorageDead</code>s by propagating those statements to other blocks, roughly speaking)</p>



<a name="163753593"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/163753593" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#163753593">(Apr 19 2019 at 18:20)</a>:</h4>
<p>but I'm not sure about this</p>



<a name="163754924"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/163754924" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#163754924">(Apr 19 2019 at 18:37)</a>:</h4>
<p>the reason we need to see <code>StorageDead</code> is because our local could have been borrowed</p>



<a name="163754933"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/163754933" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#163754933">(Apr 19 2019 at 18:37)</a>:</h4>
<p>and we can't ignore borrowed locals if we want to optimize <code>await</code></p>



<a name="163758268"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/163758268" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#163758268">(Apr 19 2019 at 19:19)</a>:</h4>
<p>Thanks <span class="user-mention" data-user-id="120791">@RalfJ</span> =)</p>



<a name="163758354"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/163758354" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#163758354">(Apr 19 2019 at 19:20)</a>:</h4>
<p><span class="user-mention" data-user-id="116883">@tmandry</span> have you seen that post? :) I'm skimming it now and then I'll re-read your comments...</p>



<a name="163758413"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/163758413" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#163758413">(Apr 19 2019 at 19:22)</a>:</h4>
<p>Though I guess it doesn't discuss StorageDead :)</p>



<a name="163758458"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/163758458" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#163758458">(Apr 19 2019 at 19:22)</a>:</h4>
<p>just the effects of redundant StorageLive</p>



<a name="163758461"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/163758461" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#163758461">(Apr 19 2019 at 19:22)</a>:</h4>
<p>^ yes</p>



<a name="163758483"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/163758483" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#163758483">(Apr 19 2019 at 19:22)</a>:</h4>
<p>I found it informative, just not for this particular question :)</p>



<a name="163758488"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/163758488" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#163758488">(Apr 19 2019 at 19:22)</a>:</h4>
<p>well, <span class="user-mention" data-user-id="116883">@tmandry</span>, I have no objection to trying to emit <code>StorageDead</code>, we should check the effects on perf though</p>



<a name="163758495"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/163758495" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#163758495">(Apr 19 2019 at 19:22)</a>:</h4>
<p><span aria-label="thumbs up" class="emoji emoji-1f44d" role="img" title="thumbs up">:thumbs_up:</span></p>



<a name="163758510"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/163758510" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#163758510">(Apr 19 2019 at 19:23)</a>:</h4>
<p>I agree that we are somehow encoding scope information</p>



<a name="163758522"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/163758522" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#163758522">(Apr 19 2019 at 19:23)</a>:</h4>
<p>But I also agree we probably want to go with using flow-control</p>



<a name="163758720"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/163758720" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#163758720">(Apr 19 2019 at 19:26)</a>:</h4>
<p>I'm thinking maybe eventually we can have an optimization pass that bubbles <code>StorageDead</code> up, based on liveness and other factors</p>



<a name="163758728"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/163758728" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#163758728">(Apr 19 2019 at 19:27)</a>:</h4>
<p>but I don't really have an idea of what that looks like :)</p>



<a name="163762303"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/163762303" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#163762303">(Apr 19 2019 at 20:22)</a>:</h4>
<blockquote>
<p>Though I guess it doesn't discuss StorageDead :)</p>
</blockquote>
<p>if you have questions about what Miri does for StorageDead, ask and you shall receive an answer. ;)</p>



<a name="163766502"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/163766502" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#163766502">(Apr 19 2019 at 21:19)</a>:</h4>
<p><span class="user-mention" data-user-id="120791">@RalfJ</span> the question I had is, is it okay to encounter StorageDead twice in a row (or more) for the same var, or StorageDead without StorageLive?</p>



<a name="163767155"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/163767155" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matthew Jasper <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#163767155">(Apr 19 2019 at 21:29)</a>:</h4>
<p>Double StorageDead already happens at the moment, and is handled properly.</p>



<a name="163768204"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/163768204" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#163768204">(Apr 19 2019 at 21:47)</a>:</h4>
<p>Miri says yes that is okay</p>



<a name="163768206"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/163768206" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#163768206">(Apr 19 2019 at 21:47)</a>:</h4>
<p>for whatever that is worth^^</p>



<a name="163770567"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/163770567" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#163770567">(Apr 19 2019 at 22:23)</a>:</h4>
<p>okay, thanks :)</p>



<a name="163776862"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/163776862" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#163776862">(Apr 20 2019 at 00:31)</a>:</h4>
<p>strangely, emitting these <code>StorageDead</code> statements causes NLL borrow check to emit fewer errors than it did before in a few tests</p>



<a name="163776868"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/163776868" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Taylor Cramer <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#163776868">(Apr 20 2019 at 00:31)</a>:</h4>
<p>I'd believe it</p>



<a name="163776871"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/163776871" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#163776871">(Apr 20 2019 at 00:31)</a>:</h4>
<p>like, it stops after the first error</p>



<a name="163776872"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/163776872" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Taylor Cramer <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#163776872">(Apr 20 2019 at 00:31)</a>:</h4>
<p>oh</p>



<a name="163776874"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/163776874" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Taylor Cramer <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#163776874">(Apr 20 2019 at 00:31)</a>:</h4>
<p>that... is not what I'd expect</p>



<a name="163776881"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/163776881" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#163776881">(Apr 20 2019 at 00:31)</a>:</h4>
<p>and when I comment that line out, then it emits the error for the next line :)</p>



<a name="163776927"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/163776927" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#163776927">(Apr 20 2019 at 00:32)</a>:</h4>
<p>this is only 3 tests, not everywhere</p>



<a name="163776929"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/163776929" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#163776929">(Apr 20 2019 at 00:32)</a>:</h4>
<p>all in <code>ui/nll/user-annotations/</code></p>



<a name="163776956"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/163776956" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#163776956">(Apr 20 2019 at 00:33)</a>:</h4>
<p>maybe there is some heuristic to remove redundant errors somewhere in NLL?</p>



<a name="163777029"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/163777029" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#163777029">(Apr 20 2019 at 00:35)</a>:</h4>
<p><span class="user-mention" data-user-id="116009">@nikomatsakis</span> any idea?</p>



<a name="163777159"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/163777159" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#163777159">(Apr 20 2019 at 00:38)</a>:</h4>
<p>here are the failures... <a href="https://gist.github.com/tmandry/8f2ed1438391b80a0b91a2452b36826f" target="_blank" title="https://gist.github.com/tmandry/8f2ed1438391b80a0b91a2452b36826f">https://gist.github.com/tmandry/8f2ed1438391b80a0b91a2452b36826f</a></p>



<a name="163926591"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/163926591" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#163926591">(Apr 22 2019 at 18:43)</a>:</h4>
<blockquote>
<p>maybe there is some heuristic to remove redundant errors somewhere in NLL?</p>
</blockquote>
<p>hmm I'm not sure</p>



<a name="163926674"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/163926674" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#163926674">(Apr 22 2019 at 18:44)</a>:</h4>
<p>ah, actually, yeah I think there <em>is</em> some kind of duplicate suppression logic</p>



<a name="163926685"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/163926685" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#163926685">(Apr 22 2019 at 18:44)</a>:</h4>
<p><span class="user-mention" data-user-id="116107">@davidtwco</span> or <span class="user-mention" data-user-id="116118">@Matthew Jasper</span> may remember more precisely</p>



<a name="163926696"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/163926696" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#163926696">(Apr 22 2019 at 18:44)</a>:</h4>
<p>but I remember <code>StorageDead</code> being relevant to errors somehow</p>



<a name="163926715"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/163926715" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#163926715">(Apr 22 2019 at 18:44)</a>:</h4>
<p>I don't have time to dig in just now</p>



<a name="163926742"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/163926742" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matthew Jasper <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#163926742">(Apr 22 2019 at 18:45)</a>:</h4>
<p>There is definitely some deduplication for storage dead errors.</p>



<a name="163927192"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/163927192" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matthew Jasper <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#163927192">(Apr 22 2019 at 18:50)</a>:</h4>
<p><a href="https://github.com/rust-lang/rust/blob/c21fbfe7e310b9055ed6b7c46b7d37b831a516e3/src/librustc_mir/borrow_check/error_reporting.rs#L701-L709" target="_blank" title="https://github.com/rust-lang/rust/blob/c21fbfe7e310b9055ed6b7c46b7d37b831a516e3/src/librustc_mir/borrow_check/error_reporting.rs#L701-L709">https://github.com/rust-lang/rust/blob/c21fbfe7e310b9055ed6b7c46b7d37b831a516e3/src/librustc_mir/borrow_check/error_reporting.rs#L701-L709</a></p>



<a name="163927350"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/163927350" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matthew Jasper <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#163927350">(Apr 22 2019 at 18:52)</a>:</h4>
<p>That doesn't appear to be what's happening here though, as the borrow spans should be different</p>



<a name="163927867"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/163927867" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matthew Jasper <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#163927867">(Apr 22 2019 at 18:57)</a>:</h4>
<p>Maybe here: <a href="https://github.com/rust-lang/rust/blob/c21fbfe7e310b9055ed6b7c46b7d37b831a516e3/src/librustc_mir/borrow_check/mod.rs#L930-L940" target="_blank" title="https://github.com/rust-lang/rust/blob/c21fbfe7e310b9055ed6b7c46b7d37b831a516e3/src/librustc_mir/borrow_check/mod.rs#L930-L940">https://github.com/rust-lang/rust/blob/c21fbfe7e310b9055ed6b7c46b7d37b831a516e3/src/librustc_mir/borrow_check/mod.rs#L930-L940</a></p>



<a name="163951264"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/163951264" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#163951264">(Apr 23 2019 at 00:37)</a>:</h4>
<p><span class="user-mention" data-user-id="116118">@Matthew Jasper</span> this definitely looks promising, thanks for pointing me to that!</p>



<a name="163951349"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/163951349" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#163951349">(Apr 23 2019 at 00:39)</a>:</h4>
<p>it seems like <code>check_for_invalidation_at_exit</code> does not do this suppression, and this function was handling checking those locals before I began emitting <code>StorageDead</code>s everywhere</p>



<a name="163951355"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/163951355" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#163951355">(Apr 23 2019 at 00:40)</a>:</h4>
<p>now <code>access_place</code> handles them which does suppression</p>



<a name="163951416"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/163951416" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#163951416">(Apr 23 2019 at 00:40)</a>:</h4>
<p>so the question is... what is the "correct" behavior?</p>



<a name="163951437"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/163951437" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#163951437">(Apr 23 2019 at 00:41)</a>:</h4>
<p>I'll push the updated tests to my upcoming PR and we can discuss there...</p>



<a name="163953693"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/163953693" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#163953693">(Apr 23 2019 at 01:40)</a>:</h4>
<p>can <span class="user-mention" data-user-id="116009">@nikomatsakis</span> or someone who can start a try run on my PR <a href="https://github.com/rust-lang/rust/issues/60187" target="_blank" title="https://github.com/rust-lang/rust/issues/60187">#60187</a>?</p>



<a name="163953744"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/163953744" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#163953744">(Apr 23 2019 at 01:40)</a>:</h4>
<p>we need to check the impact on perf of generating these <code>StorageDead</code> statements</p>



<a name="163953973"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/163953973" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#163953973">(Apr 23 2019 at 01:46)</a>:</h4>
<p><span class="user-mention" data-user-id="116466">@Zoxc</span> thanks :)</p>



<a name="163953974"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/163953974" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#163953974">(Apr 23 2019 at 01:46)</a>:</h4>
<p><span class="user-mention" data-user-id="116466">@Zoxc</span> also you'd be a great person to take a look at the PR :)</p>



<a name="164130366"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/164130366" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#164130366">(Apr 24 2019 at 23:50)</a>:</h4>
<p><span class="user-mention" data-user-id="116466">@Zoxc</span> hey.. I am trying to implement "only emit StorageDeads for generators", but I'm not sure how to get the information of _whether_ the code being lowered is in a generator</p>



<a name="164130383"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/164130383" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#164130383">(Apr 24 2019 at 23:51)</a>:</h4>
<p>today the generator-specific code just gets triggered if we hit a yield statement</p>



<a name="164130396"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/164130396" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#164130396">(Apr 24 2019 at 23:51)</a>:</h4>
<p>but I need to know for all the code when building the MIR</p>



<a name="164130502"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/164130502" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Zoxc <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#164130502">(Apr 24 2019 at 23:54)</a>:</h4>
<p>You can look up the body and see if it is a generator, <a href="https://github.com/rust-lang/rust/blob/master/src/librustc_mir/build/mod.rs#L134" target="_blank" title="https://github.com/rust-lang/rust/blob/master/src/librustc_mir/build/mod.rs#L134">https://github.com/rust-lang/rust/blob/master/src/librustc_mir/build/mod.rs#L134</a></p>



<a name="164130580"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/164130580" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#164130580">(Apr 24 2019 at 23:55)</a>:</h4>
<p>Perfect, thanks!</p>



<a name="164472658"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/164472658" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Taylor Cramer <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#164472658">(Apr 29 2019 at 17:46)</a>:</h4>
<p><span class="user-mention" data-user-id="119009">@eddyb</span> <span class="user-mention" data-user-id="116466">@Zoxc</span> are either of you around and able to review <a href="https://github.com/rust-lang/rust/pull/59897" target="_blank" title="https://github.com/rust-lang/rust/pull/59897">https://github.com/rust-lang/rust/pull/59897</a> ? it has been blocked on review for a while now</p>



<a name="164472718"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/164472718" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Taylor Cramer <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#164472718">(Apr 29 2019 at 17:47)</a>:</h4>
<p>It's also blocking further work on an issue that is tagged as blocking the release of async/await</p>



<a name="164511377"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/164511377" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#164511377">(Apr 30 2019 at 04:57)</a>:</h4>
<p>ahh, my bad, it's been slipping through</p>



<a name="164511422"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/164511422" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#164511422">(Apr 30 2019 at 04:58)</a>:</h4>
<p>I'm opening it now</p>



<a name="164512214"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/164512214" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#164512214">(Apr 30 2019 at 05:18)</a>:</h4>
<p>done. I did request some feedback from <span class="user-mention" data-user-id="116009">@nikomatsakis</span> and <span class="user-mention" data-user-id="124287">@mw</span> but I don't think it's blocking</p>



<a name="164555507"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/164555507" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#164555507">(Apr 30 2019 at 17:01)</a>:</h4>
<p>I'll take a look</p>



<a name="164743526"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/164743526" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#164743526">(May 02 2019 at 20:41)</a>:</h4>
<p><span class="user-mention" data-user-id="116466">@Zoxc</span> I replied to <a href="https://github.com/rust-lang/rust/pull/60187#discussion_r280229032" target="_blank" title="https://github.com/rust-lang/rust/pull/60187#discussion_r280229032">your comment</a> about the approach of using variants for generators</p>



<a name="164743546"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/164743546" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#164743546">(May 02 2019 at 20:41)</a>:</h4>
<p>can you let me know if this makes sense?</p>



<a name="165837752"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/165837752" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#165837752">(May 16 2019 at 18:49)</a>:</h4>
<p><span class="user-mention" data-user-id="116466">@Zoxc</span> I think <a href="https://github.com/rust-lang/rust/issues/60840" target="_blank" title="https://github.com/rust-lang/rust/issues/60840">#60840</a> is ready to merge</p>



<a name="166279085"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/166279085" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Taylor Cramer <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#166279085">(May 22 2019 at 15:29)</a>:</h4>
<p>ping <span class="user-mention" data-user-id="119009">@eddyb</span> can you take a look at <a href="https://github.com/rust-lang/rust/pull/60187" target="_blank" title="https://github.com/rust-lang/rust/pull/60187">https://github.com/rust-lang/rust/pull/60187</a> ? <span class="user-mention" data-user-id="116466">@Zoxc</span> wanted you to review the layout code changes</p>



<a name="166280971"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/166280971" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#166280971">(May 22 2019 at 15:46)</a>:</h4>
<p>I guess. I likely can't get to the review today, but I'll try to look tomorrow</p>



<a name="166281043"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/166281043" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#166281043">(May 22 2019 at 15:47)</a>:</h4>
<p>I am vaguely worried about the optimization itself, and its correctness</p>



<a name="166281709"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/166281709" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Taylor Cramer <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#166281709">(May 22 2019 at 15:54)</a>:</h4>
<p><span class="user-mention" data-user-id="119009">@eddyb</span> if you have concerns, it would be especially helpful to let <span class="user-mention" data-user-id="116883">@tmandry</span> know so we can resolve them as quickly as possible, since this is blocking async/await stabilization</p>



<a name="166281728"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/166281728" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#166281728">(May 22 2019 at 15:54)</a>:</h4>
<p>wait what</p>



<a name="166281738"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/166281738" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#166281738">(May 22 2019 at 15:54)</a>:</h4>
<p>how is this <em>blocking</em>?</p>



<a name="166281747"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/166281747" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#166281747">(May 22 2019 at 15:54)</a>:</h4>
<p>this is the first I hear of this</p>



<a name="166281774"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/166281774" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Taylor Cramer <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#166281774">(May 22 2019 at 15:55)</a>:</h4>
<p>The lang time decided to label the issue as blocking since it's causing stack overflows in a significant number of real usecases</p>



<a name="166281784"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/166281784" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Taylor Cramer <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#166281784">(May 22 2019 at 15:55)</a>:</h4>
<p>due to excessively large future types</p>



<a name="166281798"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/166281798" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#166281798">(May 22 2019 at 15:55)</a>:</h4>
<p>oh jfc</p>



<a name="166286749"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/166286749" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#166286749">(May 22 2019 at 16:51)</a>:</h4>
<p>okay I've looked and while I left a lot of comments, I'm happier now</p>



<a name="166286839"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/166286839" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#166286839">(May 22 2019 at 16:52)</a>:</h4>
<p>looks like <span class="user-mention" data-user-id="116883">@tmandry</span> picked a more straight-forward solution than what my last long discussion with them contained</p>



<a name="166288078"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/166288078" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Taylor Cramer <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#166288078">(May 22 2019 at 17:07)</a>:</h4>
<p><span class="user-mention" data-user-id="119009">@eddyb</span> thanks for taking a look! :)</p>



<a name="167018663"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/167018663" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#167018663">(May 31 2019 at 17:55)</a>:</h4>
<p><span class="user-mention" data-user-id="126931">@centril</span> did you want a timer run for <a href="https://github.com/rust-lang/rust/issues/61373" target="_blank" title="https://github.com/rust-lang/rust/issues/61373">#61373</a>?</p>



<a name="167019304"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/167019304" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#167019304">(May 31 2019 at 18:02)</a>:</h4>
<p><span class="user-mention" data-user-id="116883">@tmandry</span>  I assumed you/the reviewer did and wanted to be helpful <span aria-label="slight smile" class="emoji emoji-1f642" role="img" title="slight smile">:slight_smile:</span></p>



<a name="167031428"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/167031428" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#167031428">(May 31 2019 at 20:26)</a>:</h4>
<p>ah ok. can't hurt :)</p>



<a name="167603444"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/167603444" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#167603444">(Jun 07 2019 at 18:55)</a>:</h4>
<p><span class="user-mention" data-user-id="116466">@Zoxc</span> and also <span class="user-mention" data-user-id="119009">@eddyb</span>, would you mind taking a look at <a href="https://github.com/rust-lang/rust/issues/60187" target="_blank" title="https://github.com/rust-lang/rust/issues/60187">#60187</a>? All the changes since last review are in new commits, starting with "Small review fixes"</p>



<a name="168351212"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/168351212" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#168351212">(Jun 17 2019 at 21:57)</a>:</h4>
<p><span class="user-mention" data-user-id="116466">@Zoxc</span> How would you feel about enabling the <code>HaveBeenBorrowedLocals</code> dataflow computation in <em>all</em> generators, not just immovable ones?</p>



<a name="168351271"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/168351271" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#168351271">(Jun 17 2019 at 21:58)</a>:</h4>
<p>I need the output of it in the new dataflow stage I'm doing (so that we don't allocate two storage slots in our generator for locals that get moved from)</p>



<a name="168351309"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/168351309" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#168351309">(Jun 17 2019 at 21:59)</a>:</h4>
<p>And while, technically, we <em>could</em> get away with not doing the <code>HaveBeenBorrowedLocals</code> stage, it leads to some highly coupled code with messy types</p>



<a name="168351476"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/168351476" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Zoxc <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#168351476">(Jun 17 2019 at 22:01)</a>:</h4>
<p>It's just for immovable generators</p>



<a name="168351532"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/168351532" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#168351532">(Jun 17 2019 at 22:02)</a>:</h4>
<p>er, immovable generators, sorry</p>



<a name="168351568"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/168351568" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#168351568">(Jun 17 2019 at 22:02)</a>:</h4>
<p>Considering that I'm adding a new dataflow pass that's going to be used in all generators, I wonder if it really makes sense anymore to skip this pass on movable generators</p>



<a name="168351695"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/168351695" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#168351695">(Jun 17 2019 at 22:04)</a>:</h4>
<p>(I guess you could make the argument that my pass is only for optimization, and maybe shouldn't run when optimizations are turned off..)</p>



<a name="168351697"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/168351697" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Zoxc <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#168351697">(Jun 17 2019 at 22:04)</a>:</h4>
<p>You shouldn't rely on it's output for movable generators though. It might be a sign that what you're doing is questionable =P</p>



<a name="168351729"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/168351729" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#168351729">(Jun 17 2019 at 22:05)</a>:</h4>
<p>Well, I'm not directly relying on it</p>



<a name="168351742"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/168351742" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#168351742">(Jun 17 2019 at 22:05)</a>:</h4>
<p>The problem is, my new dataflow pass depends on the output of that <code>HaveBeenBorrowedLocals</code> pass</p>



<a name="168351817"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/168351817" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#168351817">(Jun 17 2019 at 22:06)</a>:</h4>
<p>It's technically correct to ignore borrows, if the generator is movable and we only look at the results over yield points</p>



<a name="168351827"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/168351827" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#168351827">(Jun 17 2019 at 22:06)</a>:</h4>
<p>But.. that knowledge gets spread around the code right now :/</p>



<a name="168351870"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/168351870" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#168351870">(Jun 17 2019 at 22:07)</a>:</h4>
<p>Hmm, if we do gate my new pass on optimizations being enabled</p>



<a name="168351879"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/168351879" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#168351879">(Jun 17 2019 at 22:08)</a>:</h4>
<p>..we can run <code>HaveBeenBorrowedLocals</code> only for immovable generators OR if optimizations are enabled (so my pass can consume it)</p>



<a name="168352232"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/168352232" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Zoxc <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#168352232">(Jun 17 2019 at 22:13)</a>:</h4>
<p>What does your pass do?</p>



<a name="168352880"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/168352880" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#168352880">(Jun 17 2019 at 22:22)</a>:</h4>
<p><span class="user-mention" data-user-id="116466">@Zoxc</span> It's described in <a href="https://github.com/rust-lang/rust/issues/59123#issuecomment-501089032" target="_blank" title="https://github.com/rust-lang/rust/issues/59123#issuecomment-501089032">this comment</a></p>



<a name="168352901"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/168352901" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#168352901">(Jun 17 2019 at 22:23)</a>:</h4>
<p>It can be considered a refinement of <code>MaybeStorageLive</code> for the purpose of deciding whether a local needs to be saved or not</p>



<a name="168352964"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/168352964" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#168352964">(Jun 17 2019 at 22:24)</a>:</h4>
<p>(we can decide not to save a local if it is <code>StorageLive</code> in some cases, so it becomes two independent passes)</p>



<a name="168352983"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/168352983" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#168352983">(Jun 17 2019 at 22:24)</a>:</h4>
<p>for non-optimized builds, it's possible I can fall back to using <code>MaybeStorageLive</code></p>



<a name="168353029"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/168353029" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#168353029">(Jun 17 2019 at 22:25)</a>:</h4>
<p>...but that can increase Future sizes 2x in most cases and 3x in some</p>



<a name="168650250"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/168650250" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#168650250">(Jun 21 2019 at 02:19)</a>:</h4>
<p>Okay, I think with <a href="https://github.com/rust-lang/rust/issues/61922" target="_blank" title="https://github.com/rust-lang/rust/issues/61922">#61922</a> the biggest wins for generator optimization are merged</p>



<a name="168876800"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/168876800" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#168876800">(Jun 24 2019 at 19:09)</a>:</h4>
<p>well, I mean written.. it's not merged yet :)</p>



<a name="168955961"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/168955961" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#168955961">(Jun 25 2019 at 17:00)</a>:</h4>
<p>=)</p>



<a name="169532195"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/shrinking%20generators%20%2352924/near/169532195" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/shrinking.20generators.20.2352924.html#169532195">(Jul 03 2019 at 01:12)</a>:</h4>
<p>Okay, now it's merged!</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>